package com.wholesale.beans;

import org.json.JSONException;
import org.json.JSONObject;

public class PaymentMethod {

	private int payId ;
	private String payCode ;
	private String payName ;
	private double payFee ;
	private String payDesc ;
	private String payOrder ;
	private String payConfig ;
	private boolean enabled ;
	private boolean isCod ;
	private boolean isOnline ;
	private JSONObject jsonObject;
	public int getPayId() {
		return payId;
	}
	public void setPayId(int payId) {
		this.payId = payId;
	}
	public String getPayCode() {
		return payCode;
	}
	public void setPayCode(String payCode) {
		this.payCode = payCode;
	}
	public String getPayName() {
		return payName;
	}
	public void setPayName(String payName) {
		this.payName = payName;
	}
	public double getPayFee() {
		return payFee;
	}
	public void setPayFee(double payFee) {
		this.payFee = payFee;
	}
	public String getPayDesc() {
		return payDesc;
	}
	public void setPayDesc(String payDesc) {
		this.payDesc = payDesc;
	}
	public String getPayOrder() {
		return payOrder;
	}
	public void setPayOrder(String payOrder) {
		this.payOrder = payOrder;
	}
	public String getPayConfig() {
		return payConfig;
	}
	public void setPayConfig(String payConfig) {
		this.payConfig = payConfig;
	}
	public boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	public boolean isCod() {
		return isCod;
	}
	public void setCod(boolean isCod) {
		this.isCod = isCod;
	}
	public boolean isOnline() {
		return isOnline;
	}
	public void setOnline(boolean isOnline) {
		this.isOnline = isOnline;
	}
	
	public String toJsonString(){
		JSONObject loginObject = new JSONObject();
		try {
			loginObject.put("payId", payId);
			loginObject.put("payCode", payCode);
			loginObject.put("payName", payName);
			loginObject.put("payFee", payFee);
			loginObject.put("payDesc", payDesc);
			loginObject.put("payOrder", payOrder);
			loginObject.put("payConfig", payConfig);
			loginObject.put("enabled", enabled);
			loginObject.put("isCod", isCod);
			loginObject.put("isOnline", isOnline);
		} catch (Exception e) {
		}
		return loginObject.toString();
	}
	
	public void jsonAnalytic(String jsonString){
		
		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void jsonAnalytic(JSONObject jsonObject){
		this.jsonObject = jsonObject;
		
			try {
				payId = jsonObject.getInt("payId");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payCode = jsonObject.getString("payCode");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payName = jsonObject.getString("payName");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payFee = jsonObject.getDouble("payFee");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payDesc = jsonObject.getString("payDesc");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payOrder = jsonObject.getString("payOrder");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payConfig = jsonObject.getString("payConfig");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				enabled = jsonObject.getBoolean("enabled");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				isCod = jsonObject.getBoolean("isCod");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				isOnline = jsonObject.getBoolean("isOnline");
			} catch (JSONException e) {
				e.printStackTrace();
			}
		
	}
}
